Fix NHS serial framing for embedded packet markers - #3597
Conversation
Honor the packet length declared at byte 1 so embedded 0xFF and 0xFE payload bytes do not restart or truncate valid frames. Preserve partial packet state across serial-read timeouts and validate the declared length and final marker before dispatch. Add the compatibility initialization request, model description override, protocol metadata and per-model bypass alarm behavior. Correct the published input voltage extrema and document the changes. Signed-off-by: Lucas Bocchi <lucas.bocchi@gmail.com>
|
A ZIP file with standard source tarball and another tarball with pre-built docs for commit 07f929c is temporarily available: NUT-tarballs-PR-3597.zip. |
Initialize protocol and bypass metadata explicitly for every known model so Clang's missing-field check remains clean. Add a documented defensive default to the initialization selector and teach the documentation spell checker the hexadecimal xFE token. Signed-off-by: Lucas Bocchi <lucas.bocchi@gmail.com>
Check the HWINFO checksum in its interpreter and publish the documented lower-case battery charger states. Log already-known HWINFO packets quietly and expose rejected frames through raw packet debugging. Credit the packet captures and follow-up analysis contributed in issue networkupstools#3592 directly beside the affected code and in the release notes. Suggested-by: Free Churro <freechurrosnet@gmail.com> Signed-off-by: Lucas Bocchi <lucas.bocchi@gmail.com>
|
✅ Build nut 2.8.5.5157-master completed (commit 2ba23fbcdb by @Challado)
|
Signed-off-by: Lucas Bocchi <lucas.bocchi@gmail.com>
|
✅ Build nut 2.8.5.5158-master completed (commit e5671c0355 by @Challado)
|
Pass the packet data, byte count and serial descriptor directly to the helper. Keep serial validation, reopening, write checks and diagnostics inside the helper so the initialization calls are easier to read. Signed-off-by: Lucas Bocchi <lucas.bocchi@gmail.com>
|
✅ Build nut 2.8.5.5159-master completed (commit e3c2ed0f4d by @Challado)
|
|
❌ Build nut 2.8.5.5160-master failed (commit b0c094b29b by @Challado) |
|
✅ Build nut 2.8.5.5162-master completed (commit f2bb41152b by @Challado)
|
jimklimov
left a comment
There was a problem hiding this comment.
Thanks, looks reasonable upon at least cursory review.
Reading the PR was complicated by unrelated style changes however (removing braces, gluing together multi-line debugs or large if clauses into 200+ char long single-line monsters) - do you insist on those?
|
Hi Jim,
Thank you for the review and approval.
The refactoring was intentional. I am also taking this opportunity to
teach some people on my development team about device-driver
development at this level.
To be honest with you, the code became easier for me to maintain this
way than it was before. I had written much of the original code in a
hurry, and I was already refactoring it in a separate internal Git
repository. I decided to bring the work together in this PR.
With the way I program, this structure is more intelligible to me.
There were many unnecessary loop exits and many early returns that
made me lose track of the execution flow and cost me time while
debugging. At least with the current structure, I do not get as lost
when following the code.
To be completely honest, C stopped being my main area more than 20
years ago. I sincerely apologize that these changes made the PR more
difficult to review, but I intend to continue using this programming
style so that I can keep helping with this driver without so much
difficulty reading and rereading the code several times just to find
my place again.
I hope you understand, and thank you again for taking the time to review it.
Best regards,
Lucas Bocchi
|
|
Ok, makes sense - especially if, for the time being, it is you that would be occasionally nagged and summoned to maintain these files :D until others learn the ropes... |
Summary
0xFFand0xFEinside packet payloadsNEWS.adocTesting
Hardware validation is requested from the reporter of #3592, who supplied captures demonstrating valid 18-byte and 50-byte HWINFO frames containing
0xFFin the payload.Fixes #3592